# coding=utf-8

from django import forms


class ArticleForm(forms.Form):
    title = forms.CharField(label='文章标题')
    category = forms.EmailField(label='博客标签', required=False,)
    content = forms.CharField(label='文章内容', widget=forms.TextInput)

    def clean_message(self):
        title = self.cleaned_data['title']
        num_words = len(title.split())
        if num_words < 4:
            raise forms.ValidationError("Not enough words!")
        return title
